package cn.iocoder.yudao.module.tms.dal.mysql.customerfollowup;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.tms.controller.admin.customerfollowup.vo.CustomerFollowUpPageReqVO;
import cn.iocoder.yudao.module.tms.dal.dataobject.customerfollowup.CustomerFollowUpDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CustomerFollowUpMapper extends BaseMapperX<CustomerFollowUpDO> {

    default PageResult<CustomerFollowUpDO> selectPage(CustomerFollowUpPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerFollowUpDO>()
                .eqIfPresent(CustomerFollowUpDO::getCompanyId, reqVO.getCompanyId())
                .likeIfPresent(CustomerFollowUpDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(CustomerFollowUpDO::getCompanyMode, reqVO.getCompanyMode())
                .likeIfPresent(CustomerFollowUpDO::getPrincipal, reqVO.getPrincipal())
                .likeIfPresent(CustomerFollowUpDO::getVisitor, reqVO.getVisitor())
                .eqIfPresent(CustomerFollowUpDO::getFollowStatus, reqVO.getFollowStatus())
                .betweenIfPresent(CustomerFollowUpDO::getVisitTime, reqVO.getVisitTime())
                .betweenIfPresent(CustomerFollowUpDO::getNextFollowTime, reqVO.getNextFollowTime())
                .betweenIfPresent(CustomerFollowUpDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CustomerFollowUpDO::getId));
    }

    default List<CustomerFollowUpDO> selectListByCompanyId(Long companyId) {
        return selectList(CustomerFollowUpDO::getCompanyId, companyId);
    }

}
